package common.bean;


public class PageInfo
{
	private long totalNum;//total record number in database
	private long index = 1;//page index, start at 1
	private long count;//count for each page
	
	public void validate()
	{
		if(this.getCount() < 1) throw new IllegalStateException("page length can't be less than 1.");
		if(this.getIndex() < 1) throw new IllegalStateException("page index can't be less than 1.");
		if(((this.getIndex() -1) * this.getCount()) > this.getTotalNum())
		{
			throw new IllegalStateException("You have specified an invalid page index, which out of bouds.");
		}
	}

	public long getTotalNum()
	{
		return totalNum;
	}

	public void setTotalNum(long totalNum)
	{
		this.totalNum = totalNum;
	}

	public long getIndex()
	{
		return index;
	}

	public void setIndex(long index)
	{
		this.index = index;
	}

	public long getCount()
	{
		return count;
	}

	public void setCount(long count)
	{
		this.count = count;
	}
	
}
